import request from '@/utils/request';
import { getParamsSuffix } from '@/utils/paramsUtils';

/**
 * 分页
 * @param query
 * @returns {Promise<any>}
 */
export async function listByPage(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/cerSysteminitImportInfo/listAllTableData?${params}`);
}

/**
 * 获取table的columns
 * @param query
 * @returns {Promise<any>}
 */
export async function listAllTableColumn(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/initialdatareporting/listAllTableColumn?${params}`);
}

/**
 * 获取table的columns
 * @param query
 * @returns {Promise<any>}
 */
export async function listAllTableColumn4Office(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/initialdatareporting/listAllTableColumn4Office?${params}`);
}

/**
 * 查询记录
 * @param query
 * @returns {Promise<any>}
 */
export async function findById(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/initialdatareporting/findById?${params}`);
}

/**
 * 获取table的columns
 * @param query
 * @returns {Promise<any>}
 */
export async function oneClickDelete(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/cerSysteminitImportInfo/oneClickDelete?${params}`);
}

/**
 * 分页
 * @returns {Promise<any>}
 * @param params
 */
export async function listAllTableData(params) {
  return request('/api/cdcerservice/v1/cerSysteminitImportInfo/listAllTableData', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 点击批量删除
 * @returns {Promise<any>}
 * @param params
 */
export async function batchDeletion(params) {
  return request('/api/cdcerservice/v1/cerSysteminitImportInfo/batchDeletion', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 点击存入正式库
 * @returns {Promise<any>}
 * @param query
 */
export async function insertOfficeInfo(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/cerSysteminitImportOfficialInfo/insertOfficeInfo?${params}`);
}

/**
 * 删除单条数据
 * @param params
 * @returns {Promise<any>}
 */
export async function deleteById(params) {
  return request('/api/cdcerservice/v1/initialdatareporting/deleteById', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 更新数据
 * @param params
 * @returns {Promise<any>}
 */
export async function updateRecord(params) {
  return request('/api/cdcerservice/v1/initialdatareporting/updateRecord', {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 分页
 * @returns {Promise<any>}
 * @param params
 */
export async function getPageData(params) {
  return request(`/api/cdcerservice/v1/cerSysteminitImportOfficialInfo/listAllTableData`, {
    method: 'POST',
    requestType: 'form',
    data: { ...params },
  });
}

/**
 * 查询记录
 * @param query
 * @returns {Promise<any>}
 */
export async function findDataById(query) {
  const params = getParamsSuffix(query);
  return request(`/api/cdcerservice/v1/cerSysteminitImportOfficialInfo/findDataById?${params}`);
}

/**
 * 文件选中下载
 * @returns {Promise<any>}
 * @param params
 */
export async function exportSysteminitImportInfo(params) {
    return request(`/api/cdcerservice/v1/cerSysteminitImportInfo/exportSysteminitImportInfo`, {
    method: 'POST',
    requestType: 'form',
    responseType: 'blob',
    data: {
      ...params
    }
  });
}


/**
 * 初始数据正式库的默认导出全部
 * @returns {Promise<any>}
 * @param params
 */
export async function queryAllExportData(params) {
  return request(`/api/cdcerservice/v1/cerSysteminitImportOfficialInfo/queryAllExportData`, {
    method: 'POST',
    requestType: 'form',
    responseType: 'blob',
    data: {
      ...params
    }
  });
}
